package com.wxit.datasource.controller;

import com.wxit.datasource.pojo.User;
import com.wxit.datasource.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class UserController {

    @Resource
    private UserService userService;

    @GetMapping("/v1/user/{id}")
    public User getById1(@PathVariable Integer id) {
        return userService.getByUserId1(id);
    }

    @GetMapping(value = "/v2/user/{id}")
    public User getById2(@PathVariable Integer id) {
        return userService.getByUserId2(id);
    }

    @GetMapping("/insertUserAll")
    public void insertUserAll(@RequestParam("name") String name, @RequestParam("age") int age) {
        userService.insertUserAll(name,age);
    }
}
